/*
 *  session.h
 */

#ifndef SESSION_H
#define SESSION_H

#include <string>
#include "message.h"
#include "message_dispatcher.h"
#include "message_queue.h"
#include "message_receiver.h"
#include "mutex.h"
#include "protocol.h"
#include "thread.h"
#include "socket.h"

class Session {
public:
    Session(std::string sessionID, Socket* sock, MessageQueue& q);
    ~Session();
    void sendMessage(Message* msg);
    std::string getID();
    bool isAlive();
    void kill();
    Protocol& getProtocol();
    Socket* getSocket();
protected:
    std::string sessionID;    
    Socket* sock;
    MessageDispatcher dispatcher;
    MessageReceiver receiver;
    Protocol proto;
    bool alive;    
private:
    Thread t_receiver;
    Thread t_dispatcher;
};

#endif  //SESSION_H

//{+}

